/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package boundless.entities;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author hendrikdekock
 */
@Entity
@Table(name = "ACCOUNT")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Account.findAll", query = "SELECT a FROM Account a"),
    @NamedQuery(name = "Account.findById", query = "SELECT a FROM Account a WHERE a.id = :id"),
    @NamedQuery(name = "Account.findByIsadmin", query = "SELECT a FROM Account a WHERE a.isadmin = :isadmin"),
    @NamedQuery(name = "Account.findByEmail", query = "SELECT a FROM Account a WHERE a.email = :email"),
    @NamedQuery(name = "Account.findByUsername", query = "SELECT a FROM Account a WHERE a.username = :username"),
    @NamedQuery(name = "Account.findByPassword", query = "SELECT a FROM Account a WHERE a.password = :password"),
    @NamedQuery(name = "Account.findByFirstname", query = "SELECT a FROM Account a WHERE a.firstname = :firstname"),
    @NamedQuery(name = "Account.findByLastname", query = "SELECT a FROM Account a WHERE a.lastname = :lastname")})
public class Account implements Serializable {
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "account")
    private Collection<Invitebyid> invitebyidCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "account1")
    private Collection<Invitebyid> invitebyidCollection1;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "sender")
    private Collection<Messages> messagesCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "user1")
    private Collection<Messages> messagesCollection1;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "user2")
    private Collection<Messages> messagesCollection2;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "account")
    private Collection<Invitebyemail> invitebyemailCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "ownerid")
    private Collection<Fantasyteams> fantasyteamsCollection;
    @JoinTable(name = "JOINREQUESTS", joinColumns = {
        @JoinColumn(name = "USERID", referencedColumnName = "ID")}, inverseJoinColumns = {
        @JoinColumn(name = "LEAGUEID", referencedColumnName = "ID")})
    @ManyToMany
    private Collection<League> leagueCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "ownerid")
    private Collection<League> leagueCollection1;
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    //@NotNull
    @Column(name = "ID")
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Integer id;
    @Basic(optional = false)
    //@NotNull
    @Column(name = "ISADMIN")
    private short isadmin;
    // @Pattern(regexp="[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?", message="Invalid email")//if the field contains email address consider using this annotation to enforce field validation
    @Basic(optional = false)
    //@NotNull
    @Size(min = 1, max = 50)
    @Column(name = "EMAIL")
    private String email;
    @Basic(optional = false)
    //@NotNull
    @Size(min = 1, max = 50)
    @Column(name = "USERNAME")
    private String username;
    @Basic(optional = false)
    //@NotNull
    @Size(min = 1, max = 50)
    @Column(name = "PASSWORD")
    private String password;
    @Basic(optional = false)
    //@NotNull
    @Size(min = 1, max = 40)
    @Column(name = "FIRSTNAME")
    private String firstname;
    @Basic(optional = false)
    //@NotNull
    @Size(min = 1, max = 40)
    @Column(name = "LASTNAME")
    private String lastname;

    public Account() {
    }

    public Account(Integer id) {
        this.id = id;
    }

    public Account(Integer id, short isadmin, String email, String username, String password, String firstname, String lastname) {
        this.id = id;
        this.isadmin = isadmin;
        this.email = email;
        this.username = username;
        this.password = password;
        this.firstname = firstname;
        this.lastname = lastname;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public short getIsadmin() {
        return isadmin;
    }

    public void setIsadmin(short isadmin) {
        this.isadmin = isadmin;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getFirstname() {
        return firstname;
    }

    public void setFirstname(String firstname) {
        this.firstname = firstname;
    }

    public String getLastname() {
        return lastname;
    }

    public void setLastname(String lastname) {
        this.lastname = lastname;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Account)) {
            return false;
        }
        Account other = (Account) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "boundless.entities.Account[ id=" + id + " ]";
    }

    @XmlTransient
    public Collection<League> getLeagueCollection() {
        return leagueCollection;
    }

    public void setLeagueCollection(Collection<League> leagueCollection) {
        this.leagueCollection = leagueCollection;
    }

    @XmlTransient
    public Collection<League> getLeagueCollection1() {
        return leagueCollection1;
    }

    public void setLeagueCollection1(Collection<League> leagueCollection1) {
        this.leagueCollection1 = leagueCollection1;
    }

    @XmlTransient
    public Collection<Fantasyteams> getFantasyteamsCollection() {
        return fantasyteamsCollection;
    }

    public void setFantasyteamsCollection(Collection<Fantasyteams> fantasyteamsCollection) {
        this.fantasyteamsCollection = fantasyteamsCollection;
    }

    @XmlTransient
    public Collection<Invitebyid> getInvitebyidCollection() {
        return invitebyidCollection;
    }

    public void setInvitebyidCollection(Collection<Invitebyid> invitebyidCollection) {
        this.invitebyidCollection = invitebyidCollection;
    }

    @XmlTransient
    public Collection<Invitebyid> getInvitebyidCollection1() {
        return invitebyidCollection1;
    }

    public void setInvitebyidCollection1(Collection<Invitebyid> invitebyidCollection1) {
        this.invitebyidCollection1 = invitebyidCollection1;
    }

    @XmlTransient
    public Collection<Messages> getMessagesCollection() {
        return messagesCollection;
    }

    public void setMessagesCollection(Collection<Messages> messagesCollection) {
        this.messagesCollection = messagesCollection;
    }

    @XmlTransient
    public Collection<Messages> getMessagesCollection1() {
        return messagesCollection1;
    }

    public void setMessagesCollection1(Collection<Messages> messagesCollection1) {
        this.messagesCollection1 = messagesCollection1;
    }

    @XmlTransient
    public Collection<Messages> getMessagesCollection2() {
        return messagesCollection2;
    }

    public void setMessagesCollection2(Collection<Messages> messagesCollection2) {
        this.messagesCollection2 = messagesCollection2;
    }

    @XmlTransient
    public Collection<Invitebyemail> getInvitebyemailCollection() {
        return invitebyemailCollection;
    }

    public void setInvitebyemailCollection(Collection<Invitebyemail> invitebyemailCollection) {
        this.invitebyemailCollection = invitebyemailCollection;
    }
    
}
